<?PHP
	/************************************************************************
	*       This file, in addition to all other parts of X7 Chat are        *
	*                   Copyright 2003-2007 by Tim Chamness.                *
	* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	* Version:          X7 Chat 3.0.0-A2                                    *
	* Release Date:     October 20, 2007                                    *
	* Author:           Tim Chamness                                        *
	* Copyright:        2003-2007 by Tim Chamness                           *
	* Website:          http://www.x7chat.com/                              *
	* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	* X7 Chat 3 is free software; you can redistribute it and/or modify     *
	* it under the terms of the GNU General Public License as published by  *
	* the Free Software Foundation; either version 3 of the License, or     *
	* (at your option) any later version.                                   *
	*                                                                       *
	* X7 Chat 3 is distributed in the hope that it will be useful, but      *
	* WITHOUT ANY WARRANTY; without even the implied warranty of            *
	* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
	* General Public License for more details.                              *
	*                                                                       *
	* You should have received a copy of the GNU General Public License     *
	* along with this program.  If not, see <http://www.gnu.org/licenses/>. *
	*                                                                       *
	* Additional Terms, compatible with Section 7 of the GNU GPL v3,        *
	* apply to X7 Chat 3 and all X7 Chat 3 files, including this one.       *
	* You should have received a copy of these Additional Terms in the      *
	* file docs/COPYING.ADDITIONAL_TERMS.  If you did not receive a copy    *
	* please visit <http://www.x7chat.com/COPYING.ADDITIONAL_TERMS/>.       *
	************************************************************************/

	// Make sure this file isn't being accessed directly
	if(!defined('IN_X7CHAT3')) return;
	
	$page = lib_input::read('page','tools');
		
	if(!preg_match("#^[a-z0-9_-]*$#u",$page) || !is_file("./sources/admin/{$page}.php")){
		$GLOBALS['OUTPUT']->error_message = $GLOBALS['LANG']->lang_global->not_authorised;
		echo tpl_errors::fatal_error();
		exit;
	}
	
	$menus = array(	'management'=>array(	$GLOBALS['LANG']->lang_admin->management=>'header',
						$GLOBALS['LANG']->lang_admin->manageusers=>'./index.php?act=admin&page=management',
						$GLOBALS['LANG']->lang_admin->activation=>'./index.php?act=admin&page=activation',
						$GLOBALS['LANG']->lang_admin->managebans=>'./index.php?act=admin&page=managebans',
						$GLOBALS['LANG']->lang_admin->managegroups=>'./index.php?act=admin&page=managegroups',
						$GLOBALS['LANG']->lang_admin->managerooms=>'./index.php?act=admin&page=managerooms',
					),
			'settings'=>array(	$GLOBALS['LANG']->lang_admin->settings=>'header',
						$GLOBALS['LANG']->lang_admin->configuration=>'./index.php?act=admin&page=settings',
						$GLOBALS['LANG']->lang_admin->integrationsettings=>'./index.php?act=admin&page=integration',
						$GLOBALS['LANG']->lang_admin->defaultstyles=>'./index.php?act=admin&page=defaultstyles',
						$GLOBALS['LANG']->lang_admin->managefilter=>'./index.php?act=admin&page=managefilter',
						$GLOBALS['LANG']->lang_admin->managesmilies=>'./index.php?act=admin&page=managesmilies',
						$GLOBALS['LANG']->lang_admin->events=>'./index.php?act=admin&page=events',
					),
			'appearance'=>array(	$GLOBALS['LANG']->lang_admin->appearance=>'header',
						$GLOBALS['LANG']->lang_admin->managethemes=>'./index.php?act=admin&page=appearance',
						$GLOBALS['LANG']->lang_admin->managelang=>'./index.php?act=admin&page=managelang',
					),
			'tools'=>array(		$GLOBALS['LANG']->lang_admin->tools=>'header',
						$GLOBALS['LANG']->lang_admin->tools_main=>'./index.php?act=admin&page=tools',
						$GLOBALS['LANG']->lang_admin->updatemanager=>'./index.php?act=admin&page=updatemanager',
						//'modmanager'=>'./index.php?act=admin&page=modmanager',
						//'maintenance'=>'./index.php?act=admin&page=maintenance',
					),
			);
	
	// Permission check
	$pvar = 'ACP_'.strtoupper($page).(isset($_GET['section']) ? '_'.strtoupper($_GET['section']) : '');
	if(!$ses->user->has_permission($pvar)){
		$GLOBALS['OUTPUT']->error_message = $GLOBALS['LANG']->lang_global->not_authorised;
		echo tpl_errors::fatal_error();
		exit;
	}
		
	$GLOBALS['OUTPUT']->set_theme('admin');
	$GLOBALS['OUTPUT']->cpmenu = $menus;
	
	include("./sources/admin/{$page}.php");
?>